<?php
# http://192.168.18.23/master/mcGM/tmp_process/record_idfa.php?device_id=1&idfa=AE808645-48AF-46CF-A63A-BF5072D6CE5A
#http://192.168.18.23/master/mcGM/tmp_process/record_idfa.php?device_id=2&idfa=5A58EF1E-EEF2-478D-94EE-709B98407589
#http://192.168.18.23/master/mcGM/tmp_process/record_idfa.php?device_id=3&idfa=A0A82816-3383-437B-A535-F910162A7098

#http://192.168.18.23/master/mcGM/tmp_process/record_idfa.php?device_id=4&idfa=5A58EF1E-EEF2-478D-94EE-709B98407589
#http://192.168.18.23/master/mcGM/tmp_process/record_idfa.php?device_id=5&idfa=A0A82816-3383-437B-A535-F910162A7097
#http://192.168.18.23/master/mcGM/tmp_process/record_idfa.php?device_id=6&idfa=A0A82816-3383-437B-A535-F910162A7098


define("APP_ROOT",dirname(__FILE__) . "/");

include APP_ROOT . "cur_db_cfg.php";

# 解析URL数据
$row = $_GET;
$appid = '1065398803';

$query = "SELECT * FROM device_lan WHERE device_id = '" . $row["device_id"] . "'";

#var_dump($query);
$conn=mysql_connect($dbhost_idfa,$dbaccount_idfa,$dbpwd_idfa);
mysql_select_db("shouhuzhemen_account");
$result_db = mysql_query($query);

var_dump($result_db);
if(false != $result_db)
{
    db_option($row, $appid);
}

function db_option($rowdata, $appid)
{
    $strdata = "insert into device_lan(device_id, appid, idfa) values('";
    $strdata = $strdata . $rowdata['device_id'] . "', '";
    $strdata = $strdata . $appid . "', '";
    $strdata = $strdata . $rowdata['idfa'] . "') on duplicate key update ";
    $strdata = $strdata . "appid='$appid',";
    $strdata = $strdata . "idfa='$rowdata[idfa]'";
    
    #echo($strdata . "<br>");
    $result_db=mysql_query($strdata);
    if(true == $result_db)
    {
        echo("successful");
    }
    else
    {
        echo("failed");
    }
}
?>
